package com.huq.io;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.concurrent.ConcurrentHashMap;

public class SessionManager {
    private Charset charset = Charset.forName("UTF-8");

    public static ConcurrentHashMap<String, IOSession> sessionMap = new ConcurrentHashMap<String, IOSession>();

    public static void write(String key, ByteBuffer b) {
	IOSession ses = sessionMap.get(key);
	if (ses == null) {
	    ses = new IOSession();
	    sessionMap.put(key, ses);
	}
	ses.setKey(key);
	ses.setValue((ses.getValue() == null ? b : ses.getValue().put(b)));
    }

    public static IOSession getSession(String key) {
	return sessionMap.get(key);
    }

}
